package com.wtp.wallpaper.handler;

import com.wtp.wallpaper.common.exception.BaseException;
import com.wtp.wallpaper.pojo.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    @ExceptionHandler
    public Result exceptionHandler(BaseException e){
        log.error("异常信息:{}",e.getMessage());
        return Result.error(e.getMessage());
    }
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
        String s = "上传文件大小超出限制";
        log.error("异常信息:{}",s);
        return Result.error(s);
    }

}
